struct mkshort_handle_imp; // forward declare, definition in mkshort.cc
using short_handle = mkshort_handle_imp*;
-char* mkshort(short_handle, const char*);
+char* mkshort(short_handle, const char*, bool);
QString mkshort(short_handle, const QString&);
short_handle mkshort_new_handle();
QString mkshort_from_wpt(short_handle h, const Waypoint* wpt);
void setshort_whitespace_ok(short_handle, int n);
void setshort_repeating_whitespace_ok(short_handle, int n);
void setshort_defname(short_handle, const char* s);
-void setshort_is_utf8(short_handle h, int is_utf8);
#define ARGTYPE_UNKNOWN 0x00000000
#define ARGTYPE_INT 0x00000001
*/
char* ident = mkshort(mkshort_handle,
global_opts.synthesize_shortnames ? CSTRc(src) :
- CSTRc(wpt->shortname));
+ CSTRc(wpt->shortname), false);
/* Should not be a strcpy as 'ident' isn't really a C string,
* but rather a garmin "fixed length" buffer that's padded
* to the end with spaces. So this is NOT (strlen+1).
setshort_length(mkshort_handle, sLen);
setshort_mustuniq(mkshort_handle, 0);
- char* shortstr = mkshort(mkshort_handle, stIn);
+ char* shortstr = mkshort(mkshort_handle, stIn, false);
strcpy(strTmp,shortstr);
xfree(shortstr);
#include "defs.h"
#include "cet.h" // for cet_utf8_strdup, cet_utf8_strlen, cet_utf8_strndup
-#include "cet_util.h" // for cet_cs_vec_utf8
#define MYNAME "mkshort"
bool whitespaceok{true};
bool repeating_whitespaceok{false};
bool must_uniq{true};
- bool is_utf8{false};
};
static struct replacements {
h->badchars = xstrdup(DEFAULT_BADCHARS);
h->defname = xstrdup("WPT");
- h->is_utf8 = (global_opts.charset == &cet_cs_vec_utf8);
return h;
}
hdl->must_uniq = i;
}
-/*
- * Declare that actually characters are (or are not) encoded in UTF-8.
- */
-void
-setshort_is_utf8(short_handle h, const int is_utf8)
-{
- mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
- hdl->is_utf8 = is_utf8;
-}
-
char*
-mkshort(short_handle h, const char* istring)
+mkshort(short_handle h, const char* istring, bool is_utf8)
{
char* ostring;
char* tstring;
int i, l, replaced;
mkshort_handle_imp* hdl = (mkshort_handle_imp*) h;
- if (hdl->is_utf8) {
+ if (is_utf8) {
ostring = cet_utf8_strdup(istring); /* clean UTF-8 string */
} else {
ostring = xstrdup(istring);
* If the numeric component alone is longer than our target string
* length, use only what'll fit.
*/
- if (hdl->is_utf8) {
+ if (is_utf8) {
/* ToDo: Keep trailing numeric data as described above! */
if (cet_utf8_strlen(ostring) > hdl->target_len) {
char* tmp = cet_utf8_strndup(ostring, hdl->target_len);
QString
mkshort(short_handle h, const QString& istring)
{
- char* t = mkshort(h, CSTR(istring));
+ char* t = mkshort(h, CSTR(istring), true);
QString r(t);
xfree(t);
return r;
static void
psit_waypoint_w(gbfile* psit_file, const Waypoint* wpt)
{
- char* src = nullptr; /* BUGBUG Passed to mkshort */
-
gbfprintf(psit_file, "%11.6f,%11.6f,",
wpt->latitude,
wpt->longitude);
wpt->altitude);
const char* ident = global_opts.synthesize_shortnames ?
- mkshort(mkshort_handle, src) :
+ mkshort(mkshort_handle, "WPT", false) :
xstrdup(wpt->shortname);
gbfprintf(psit_file, " %-6s, ", ident);
}
}
- wpt->extra_data = (void*)mkshort(hshort_wpt, CSTRc(wpt->shortname));
+ wpt->extra_data = (void*)mkshort(hshort_wpt, CSTRc(wpt->shortname), false);
waypt_table[waypt_table_ct] = wpt;
waypt_table_ct++;
-$PMGNGEO,4608.000,N,7300.000,W,0000,F,GC7FA4,Points godsiques,Sverdrup2,,Locationless (Reverse) Cache,1508102,1207105,1.0,1.0*7A\r
+$PMGNGEO,4608.000,N,7300.000,W,0000,F,GC7FA4,Points godsiques d,Sverdrup2,,Locationless (Reverse) Cache,1508102,1207105,1.0,1.0*3E\r
$PMGNGEO,3555.300,N,8651.700,W,0000,F,GCGCA8,Oozy rat in a sanita,robertlipe,There Is No Hint,Mystery Cache,2906103,0307105,3.0,2.0*04\r
$PMGNCMD,END*3D\r